package com.wdz.task;

import com.wdz.http.Response;
import com.wdz.websocket.WebSocket;

import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;

public class UserTaskService extends TimerTask {
    private String userId;

    //提醒用户登录信息失效
    public void run(){
        WebSocket webSocket = WebSocket.webSocketSet.get(userId);
        Response response = new Response(401,0,"用户信息已失效，请重新登录！","");
        try {
            webSocket.sendMessage(response.toJsonString());
            webSocket.onClose();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }
}
